package com.huixuebao.after.controller.login;


import com.huixuebao.after.dto.LoginDTO;
import com.huixuebao.after.dto.SmsCodeDTO;
import com.huixuebao.after.service.CaptchaService;
import com.huixuebao.after.service.LoginService;
import com.huixuebao.common.bean.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@Slf4j
@RestController
@RequestMapping("/hxb/after/login")
public class loginController {

    @Autowired
    private CaptchaService captchaService;
    @Autowired
    private LoginService loginService;

    /**
     * 验证码登陆
     * @return
     */
    @PostMapping("/login")
    public ApiResult login(@RequestBody LoginDTO loginDTO){
        return loginService.login(loginDTO);
    }

    /**
     * @author fatao_yu
     * 获取短信验证码
     * @param smsCodeDTO
     * @return
     */
    @PostMapping("/getSmsCode")
    public ApiResult getSmsCode(@RequestBody SmsCodeDTO smsCodeDTO){
        return loginService.getSmsCode(smsCodeDTO);
    }
    /**
     * 校验手机号码
     * @param loginDTO
     * @return
     */
    @GetMapping("/checkMobile")
    public ApiResult checkMobile(@RequestParam LoginDTO loginDTO){
        return captchaService.checkMobile(loginDTO);
    }

}
